﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Services.Common;
using Microsoft.WindowsAzure.StorageClient;

namespace CPlase.Lists
{
    [DataServiceKey("PartitionKey", "RowKey")]
    public abstract class NumeratableListItemEntity : TableServiceEntity, IComparable<NumeratableListItemEntity>, IComparable
    {
        override public string PartitionKey { get; set; }
        override public string RowKey { get; set; }
        
        /// <summary>
        /// Идентификатор списка
        /// </summary>
        public string ListID { get; set; }

        /// <summary>
        /// Номер позиции в списке
        /// </summary>
        public Int32 Position { get; set; }

        public int CompareTo(NumeratableListItemEntity other)
        {
            if (other != null)
                return Position.CompareTo(other.Position);
            return -1;
        }

        public int CompareTo(object obj)
        {
            if (obj is NumeratableListItemEntity)
                return CompareTo(obj as NumeratableListItemEntity);
            return -1;
        }
    }
}